<?php

namespace AuctionBack\Controller;

use AuctionCore\Other\LakalaBill;
use AuctionCore\Common\Page;

/**
 * 财务对账
 */
class CheckAccountsController extends BaseController
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $p = I('get.p/d',1);
        $page_size = 8;
        $params = array(
            'start_date' => I('get.start_date'),
            'end_date' => I('end_date')
        );
        $La = new LakalaBill();

        $list = $La->getList($p,$page_size,$params);
        $total = $La->getTotal($params);
        $Page = new Page($total, $page_size);
        $show = $Page->platform_show();
        $this->assign('page',$show);
        $this->assign('list', $list);
        $this->assign("params", $params);
        $this->display();
    }

    public function detail()
    {
        $day = I('get.day', '');
        if (empty($day)) {
            $this->helpJsRedirect("参数不正确");
        }
        $p = I('get.p/d', 1);
        $limit = 10;
        $dealer_id = I("get.dealer_id",'');
        $real_name = I("get.real_name",'');
        $mobile = I('get.mobile','');
        $bc_id = I('get.bc_id',-1);
        $La = new LakalaBill();
        $result = $La->getDetailList($p, $limit,$day,$dealer_id,$real_name,$mobile,$bc_id);
        $list = empty($result['list']) ? array() : $result['list'] ;
        $total = $result['total']>0 ? $result['total'] : $result['total'] ;
        $Page = new Page($total, $limit);
        $show = $Page->platform_show();
        //分公司列表
        $bc_list = $this->get_branch_company_list();
        $this->assign('bc_list', $bc_list);
        $this->assign('list', $list);
        $this->assign('page', $show);
        $this->assign('bc_id',$bc_id);
        $this->assign('day',$day);
        $this->assign('dealer_id',$dealer_id);
        $this->assign('real_name',$real_name);
        $this->assign('mobile',$mobile);
        $this->display();
    }
}